<!--
 * @Author: ChunLai
 * @Date: 2023-03-17 14:14:44
 * @LastEditTime: 2023-09-05 20:31:45
 * @Description: pdf非必读文档
 * @FilePath: \0.newInsure\src\views\sign\components\protocols\PdfList.vue
-->
<template>
  <div class="protocol">
    <div class="notice_img" @click="readClick">
      <span class="check_img" v-if="pdfFinish"></span>
    </div>
    <div class="clause_ul">
      <i>本人已充分阅读、理解并同意</i>
      <em
        v-for="(item, index) in lists"
        :key="`pdflists-${index}`"
        @click.stop="openPdf(item)"
      >
        {{ getFileName(item, index) }}
      </em>
    </div>
    <PdfFileDisplay ref="pdfFilePop" />
  </div>
</template>

<script>
import { mapGetters } from 'vuex';
import PdfFileDisplay from '../PdfFileDisplay';
export default {
  name: 'PdfList',
  data() {
    return {};
  },
  components: { PdfFileDisplay },
  computed: {
    ...mapGetters({
      lists: 'readings/pdfLists',
      pdfFinish: 'readings/pdfFinish',
    }),
  },
  created() {},
  mounted() {},
  watch: {},
  methods: {
    getFileName(item, index) {
      let res = '',
        symbol = '',
        name = `${item.fileName || ''}`;
      if (index != this.lists.length - 1) {
        symbol = '、';
      }
      if (name && name.indexOf('《') == -1) {
        name = `《${name}》`;
      }
      res = `${name}${symbol}`;
      return res;
    },
    readClick() {
      this.$store.dispatch('readings/setItemFinish', {
        type: 'pdf',
      });
    },
    openPdf(item) {
      if (!item.fileUrl) return this.$toast('未查询到该文件');
      this.$refs.pdfFilePop.initModule(item);
    },
  },
};
</script>

<style lang="less" scoped>
@import './style.less';
</style>
